x86 vtsc: use debug-key to check/test reliable tsc
authorKeir Fraser <keir.fraser@citrix.com>
Wed, 7 Oct 2009 06:43:50 +0000 (07:43 +0100)
committerKeir Fraser <keir.fraser@citrix.com>
Wed, 7 Oct 2009 06:43:50 +0000 (07:43 +0100)
commitc4debc45154cd6821805cfa6175e42d67f11d310
tree632e182ccd513ce05a42fc660515677e7fe76dfb
parent174a32019e2f223efa276b72c8c86f4003f76764
x86 vtsc: use debug-key to check/test reliable tsc

Previous attempt was rejected as too intrusive, but
further app rdtsc optimization work is very dependent
on Xen being able to determine if TSC is reliable
or not.

This patch starts to introduce the concept of
X86_FEATURE_TSC_RELIABLE as it is defined and
used by Linux, but uses it and tests it only in
a debug-key for now, so that a wide variety of
hardware can be measured by the broader Xen
community to confirm/deny TSC assumptions.
The eventual goal is for the evaluation of
TSC reliability to be exported to userland
so that apps can use rdtsc natively if and when
it is safe to do so.

(See http://lists.xensource.com/archives/html/xen-devel/2009-10/msg00056.html)

Note that the original Linux code for tsc_sync.c
uses a raw spinlock to ensure the "fastest, inlined,
non-debug version of a critical section".  Xen
doesn't provide a _raw_spin_lock() so I used
regular spinlocks, but I would prefer the code
to use something more strict as Linux does.

(Also includes a minor nit: "NOSTOP" was used in
an early version of a Linux patch, but mainline
now uses "NONSTOP"... correct this for consistency.)

Signed-off-by: Dan Magenheimer <dan.magenheimer@oracle.com>
xen/arch/x86/cpu/amd.c
xen/arch/x86/cpu/intel.c
xen/arch/x86/time.c
xen/include/asm-x86/cpufeature.h